package cn.myblog.ainblog.conroller;

import cn.myblog.ainblog.service.ArticleService;
import cn.myblog.ainblog.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;


/**
 * @author Dovaior
 * @Description 标签子页面的控制器
 * @create 2021-05-05 07:59
 **/
@Controller
public class TagSubController {
    @Autowired
    private TagService tagService;
    @Autowired
    private ArticleService articleService;
    @GetMapping("/tag_subpage/{tagId}")
    public String tagSubpage(@PathVariable String tagId, Model model){
        //指定id的标签的全部信息
        model.addAttribute("tagModel",tagService.selectById(tagId));
        //指定标签的全部博文
        model.addAttribute("articlesByTag",articleService.queryArticleListByTag(tagId));
        return "tag-subpage";
    }
}
